package com.sdy.usercenter.biz.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sdy.auth.api.model.UserInfo;
import com.sdy.common.model.BizException;
import com.sdy.common.model.PageQuery;
import com.sdy.common.model.PageResult;
import com.sdy.usercenter.biz.model.SysUser;
import com.sdy.mvc.service.BaseService;
import com.sdy.usercenter.biz.model.vo.UserRoleVO;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户基础信息表 服务类
 * </p>
 *
 * @author zzq
 * @since 2019-06-14
 */
public interface SysUserService extends BaseService<SysUser> {
    void saveUser(SysUser sysUser) throws BizException;
    void updateUser(SysUser user) throws BizException;
    void updateWithNullTime(SysUser user) throws BizException;
    IPage<SysUser> pageUserWithRole(IPage<SysUser> page, Map<String, Object> query, Integer roleId, Boolean contain);

    void modifyPassword(Integer userId, String password);

    /**
     * 开户
     * @param vo
     * @param opUserInfo 操作用户
     */
    void openAccount(SysUser vo, UserInfo opUserInfo, String ip) throws Exception;

    /**
     * 查询部门下的用户
     * @param deptId
     * @param username
     * @param recursively 递归查询
     * @return
     */
    PageResult<SysUser> pageUserInDept(PageQuery page, Integer deptId, String username, Boolean recursively);

    IPage<SysUser> pageUserWithApp(Page<SysUser> page, Map<String, Object> query, Integer appId, Boolean contain);
    
    boolean checkUsernameUnique(String username, Integer userId, Integer deptId);
    String getUserDeptSuffix(Integer userId, Integer deptId);

    /**
     * 获取用户角色信息
     * @param userId 用户id
     * @param authOnly 是否只包含有权限的角色
     * @return
     */
    List<UserRoleVO> listUserRole(Integer userId, Boolean authOnly);

    /**
     * 获取用户角色信息
     * @param userId 用户id
     * @param roleIdList 角色ID列表
     * @return
     */
    void updateUserRole(Integer userId, List<Integer> roleIdList);
}
